import request from "@/utils/request";

// 查询所有部门信息
export const queryAllApi = () =>{
    return  request.get('/depts')
}

// 新增部门
export const addDeptApi = (data) =>{
    return request.post('/depts', data)
}

// 删除部门
export const deleteDeptApi = (id) =>{
    return request.delete(`/depts/${id}`)
}

// 根据ID查询部门信息
export const queryByIdApi = (id) =>{
    return request.get(`/depts/${id}`)
}

// 修改部门
export const updateDeptApi = (dept) =>{
    return request.put('/depts', dept)
}

// 根据父节点查询子节点
export const queryChildByParentIdApi = (parentId) =>{
    return request.get(`/depts/children?parentId=${parentId}`)
}

// 根据角色ID查询部门列表
export const queryDeptListByRoleIdApi = (roleId) =>{
    return request.get(`/roles/${roleId}/depts`)
}

// 根据用户ID查询部门列表
export const queryDeptListByUserIdApi = (userId) =>{

    return request.get(`/users/${userId}/depts`)
}